package com.xqq.config;

import io.minio.MinioClient;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import javax.annotation.PostConstruct;

@Configuration
public class MinioClientConfig {

    @Value("${minio.endpoint}")
    private String minioEndpoint;

    @Value("${minio.accesskey}")
    private String minioAccessKey;

    @Value("${minio.secretkey}")
    private String minioSecretKey;

    @Value("${minio.bucketUrl}")
    private String bucketUrl;

    @Value("${minio.bucketName}")
    private String bucketName;

    public static String minioUploadUrl;
    public static String minioBucketName;


    @PostConstruct
    public void fillFollowUserList() {
        minioUploadUrl =  bucketUrl ;
        minioBucketName = bucketName;
    }

    @Bean
    public MinioClient minioClient() {
        return MinioClient.builder()
                .endpoint(minioEndpoint)
                .credentials(minioAccessKey, minioSecretKey)
                .build();
    }
}
